/*
 * \file BaseAbilitiesWidget.h
 *
 * \date Created on: Jan 21, 2009
 * \author sarah
 */

#ifndef BASEABILITIESWIDGET_H_
#define BASEABILITIESWIDGET_H_

#include <QWidget>

#include <DndData/DndData.h>

#include "ui_baseabilitiespage.h"

class QStandardItemModel;
class CharacterData;
class QSlider;

class BaseAbilitiesWidget: public QWidget
{
	Q_OBJECT

public:
	enum AbilityTabs {
		StandardArrayTab,
		CustomizeScoresTab,
		RollDiceTab
	};

        BaseAbilitiesWidget(CharacterData *data, QWidget *parent = 0);
	virtual ~BaseAbilitiesWidget();

public Q_SLOTS:
	void updateToClass(int);

private Q_SLOTS:
	void abilitySliderChanged();
	void initialize();
	void on_rerollPushButton_clicked(bool);
	void on_abilitiesTabWidget_currentChanged(int);

private:
    bool checkChangesOk(const QString &);
    int setToClosest(int, int);
    void redistributeValues(int, int, int);
    int maintainCustomizePoints(int, int, int);
    void setAbilityArray(const int[]);
    int checkLowSlider(QSlider*);
    int clipToRange(int, int);
    void modifierTotalUpdate();
    void updateDiceRoll();
    int *getRandomArray();

    Ui::BaseAbilitiesWidget mPage;
    QStandardItemModel *mAbilityArrayModel;
    QSlider **mAbilityArraySliders;
    std::map<QSlider*, int> mPreviousIndexes;
    int mAbilityArray[DndData::NUM_ABILITIES];
    CharacterData *mCharacterData;
    bool mSlidersModified;
    bool mSlidersModifiedWarningGiven;
    int mCustomPoints;
    bool mLowAbilityWarningGiven;
    int mRerollCount;
};

#endif /* BASEABILITIESWIDGET_H_ */
